import request from '@/utils/request.ts'
import { queryParams } from '@/api/system/common'

enum API {
  DICT_TYPE_LIST_URL = '/system/dict/type/list' /*获取全部字典类型信息*/,
  DICT_TYPE_ADD_URL = '/system/dict/type/add' /*添加字典类型*/,
  DICT_TYPE_EDIT_URL = '/system/dict/type/edit' /*修改字典类型*/,
  DICT_TYPE_DELETE_URL = '/system/dict/type/delete' /*删除字典类型*/,
  DICT_TYPE_REFRESH_CACHE_URL = '/system/dict/type/refreshCache' /*清除缓存字典*/,

  DICT_GET_INFO_URL = '/system/dict/type/info' /*根据id来获取菜单信息，进行回显*/,
  DICT_TYPE_OPTION_SELECT = '/system/dict/type/optionselect' /*获取所有的字典类型*/,
}

//分页查询
export const reqDictTypePageListUrl = (queryParams: any) => {
  return request({
    url: API.DICT_TYPE_LIST_URL,
    method: 'get',
    params: queryParams,
  })
}
//类型添加
export const reqDictTypeAddUrl = (form: any) => {
  return request({
    url: API.DICT_TYPE_ADD_URL,
    method: 'post',
    data: form,
  })
}

//类型修改
export const reqDictTypeEditUrl = (form: any) => {
  return request({
    url: API.DICT_TYPE_EDIT_URL,
    method: 'put',
    data: form,
  })
}

//类型删除
export const reqDictTypeDeleteUrl = (dictIds: any) => {
  return request({
    url: API.DICT_TYPE_DELETE_URL + '/' + dictIds,
    method: 'delete',
  })
}

// 刷新字典缓存
export const reqRefreshCacheUrl = () => {
  return request({
    url: API.DICT_TYPE_REFRESH_CACHE_URL,
    method: 'delete',
  })
}

//根据id来获取菜单信息，进行回显
export const reqDictTypeInfoUrl = (dictId: number) => {
  return request({
    url: API.DICT_GET_INFO_URL + '/' + dictId,
    method: 'get',
  })
}

/*获取所有类型*/
export const getDictTypeAllUrl = () => {
  return request({
    url: API.DICT_TYPE_OPTION_SELECT,
    method: 'get',
  })
}
